package cn.wen.forum.mapper;

import cn.wen.forum.pojo.entity.Post;
import cn.wen.forum.vo.PostVO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

/**
 * @ClassName ForumMapper
 * @Author By wen
 * @Description  tb_post 帖子表mapper
 * @Date 2023/3/7 16:49
 * @Version 1.0
 */
@Repository
public interface PostMapper extends BaseMapper<Post> {

    /**
     * 获取帖子以及用户信息
     * @param id
     * @return
     */
    @Select("select T1.head_portrait,T1.level,T1.empirical_value,T1.admini_strator, T2.* " +
            "from tb_post T2 join tb_user T1 " +
            "on T2.id = #{id} and T1.id = T2.user_id"
    )
    PostVO selectPostAndUserInfoById(String id);
}
